<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'add.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="css/css.css" rel="stylesheet" type="text/css" />
   <script src="js/jquery-1.9.1.min.js"></script>
  </head>
  
  <body>

 <form action="marketing/zaddMarketing.do" method="post" name="f1">
 <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox04table">
            <tr>
              <td class="ybox04tdl"><span class="red">*</span> 机会名称：</td>
              <td class="ybox04tdr" colspan="7"><input name="name" type="text"  class="black12" id="textfield9"  value="" /></td>
            </tr>
            <tr>
            
              
               <td  class="ybox04tdl"><span class="red">*</span> 意向项目：</td>
              <td  class="ybox04tdr">
              <select name="project" id="project" onChange="change3()">
               <option value="">-------请选择--------</option>
               <c:forEach items="${list1}" var="p">
               <option value="${p.id}">------${p.name}---</option>
               </c:forEach>
               </select>
              </td>
              <td class="ybox04tdl"><span class="red">*</span> 意向楼栋：</td>
              <td class="ybox04tdr">
              
              <select name="complex" id="complex" onChange="change1()">
              <option value="">--------请选择-------</option>
               </select>
              
              </td>
              <td class="ybox04tdl"><span class="red">*</span> 意向单元：</td>
              <td class="ybox04tdr">
              <select name="unit" id="unit"  onchange="change2()">
              <option value="">--------请选择-------</option>
               </select>
              
              </td>
               <td class="ybox04tdl"><span class="red">*</span>意向房间：</td>
              <td class="ybox04tdr">
               <select name="roomid" id="roomid">
              <option value="">--------请选择-------</option>
               </select>
              
              
              </td> 
              
              
            </tr>
            <tr>
            
              <td  class="ybox04tdl"><span class="red">*</span> 客户姓名：</td>
              <td  class="ybox04tdr">
              <select name="clientname" onChange="tochange()">
               <option value="">-----请选择------</option>
               <c:forEach items="${list3}" var="cl">
               <option value="${cl.id}">-----${cl.clientidname}------</option>
               </c:forEach>
               </select>
           
              <td class="ybox04tdl"><span class="red">*</span> 联系方式：</td>
              <td class="ybox04tdr">
               <select name="clinetelephone" id="clinetelephone">
               <option value="">-----请选择------</option>
              </select>
              </td>
              <td class="ybox04tdl">业务员编号：</td>
               <td class="ybox04tdr">
               <select name="userid" id="userid" onChange="tochange1()">
               <option value="">-----请选择------</option>
               <c:forEach items="${list}" var="l">
               <option value="${l.id}">-----${l.id}------</option>
               </c:forEach>
               </select>
           
              <td class="ybox04tdl">业务员姓名：</td>
               <td class="ybox04tdr"><input name="username" id="username" type="text" readonly="readonly"></td>
              
            </tr>
            
            
            
            <tr>

				<td class="ybox04tdl"><span class="red">*</span> 状态：</td>
				<td colspan="7" class="ybox04tdr">
						<label><input name="state" type="radio" class="ace"
							value="草稿"><span class="lbl">草稿</span>
						</label>&nbsp;&nbsp;&nbsp;
     <label><input name="state" type="radio" class="ace"
							value="关闭"><span class="lbl">关闭</span>
						</label>
					</td>
			<tr>
            
            
      
            <tr>
            
              <td  class="ybox04tdl"><span class="red">*</span> 意向描述</td>
              <td colspan="7"  class="ybox04tdr"> <textarea name="intention" style="width:300px;height:100px; " class="form-control" id="意向描述" placeholder="" onKeyUp="checkLength(this);"></textarea><br/><br/>
     <span class="wordage">剩余字数：<span id="sy" style="color:Red;">200</span>字</span></div><br/><br/>
    </td>
           
            <tr>
              <td  class="ybox04tdr"  colspan="8"><span class="red"><input type="submit" value="提交"/>
               <input type="button" value="取消" onClick="end()"/>  </td>
            </tr>
          </table>
</form>

  </body>
  
</html>
<script>
function tochange(){
  			
  				 var cid=document.f1.clientname.value;
  				
  				
  				 $.ajax({
  					url:"marketing/toajax11.do",
  					type:"post",
  					dataType:"text",
  					data:{cid:cid},
  					success:function(requestXMLTest){
  						    
  			       $("#clinetelephone").empty();
			       $("#clinetelephone").append(requestXMLTest);
  			           
  					},
  					error:function(){
  						alert("error");
  					}
  				});
  				
  			}
  			

function tochange1(){
  			
  				 var userid=document.f1.userid.value;
  				  var url="marketing/toajax1.do";
  				 $.ajax({
  					url:url,
  					type:"post",
  					dataType:"text",
  					data:{userid:userid},
  					success:function(requestXMLTest){
  			           document.f1.username.value=requestXMLTest;
  					},
  					error:function(){
  						alert("error");
  					}
  				});
  				
  			}
  			



function checkLength(which) {
	var maxChars = 200; //
	if(which.value.length > maxChars){
	   layer.open({
	   icon:2,
	   title:'提示框',
	   content:'您出入的字数超多限制!',	
    });
		// 超过限制的字数了就将 文本框中的内容按规定的字数 截取
		which.value = which.value.substring(0,maxChars);
		return false;
	}else{
		var curr = maxChars - which.value.length; //250 减去 当前输入的
		document.getElementById("sy").innerHTML = curr.toString();
		return true;
	}
};


 function end(){
	window.location.href = "marketing/marketing.do";       
} 

  	
  	function change3(){
  				 var project=document.f1.project.value;
  				
	$.ajax({
			url : "marketing/toajax2.do",
			type : "post",
			dataType : "text",
			data : {project : project},
			success : function(requestXMLTest) {
			$("#complex").empty();
			  $("#complex").append(requestXMLTest);
			},
			error : function() {
				alert("error");
			}
		});

	}
	
	
	
	
function change1(){
   var complex=document.f1.complex.value;
  				
	$.ajax({
			url : "marketing/toajax3.do",
			type : "post",
			dataType : "text",
			data : {complex : complex},
			success : function(requestXMLTest) {
			
			$("#unit").empty();
			  $("#unit").append(requestXMLTest);
			},
			error : function() {
				alert("error");
			}
		});

	}
	
	function change2(){
   var unit=document.f1.unit.value;		
	$.ajax({
			url : "marketing/toajax4.do",
			type : "post",
			dataType : "text",
			data : {unit : unit},
			success : function(requestXMLTest) {
			$("#roomid").empty();
			  $("#roomid").append(requestXMLTest);
			},
			error : function() {
				alert("error");
			}
		});

	}	



  	
  	
  	
  	
  	
</script>




